﻿using System.Data;
using System.IO;
using System.Text;

namespace WebVisualizers.Helpers
{
    internal static class DataHelper
    {
        /// <summary>
        /// Creates an Xml from the TabaTable and returns it as a string
        /// </summary>
        internal static string GetXmlFromDataTable(DataTable dt)
        {
            //Create a copy of the datatable so we can change it
            DataTable dtCopy = dt.Copy();
            dtCopy.TableName = dtCopy.TableName.Replace(" ", "");

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            
            dtCopy.WriteXml(sw,true);

            return sb.ToString();
        }
    }
}
